import { defineComponent, ref, h, isVNode, computed, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, resolveDynamicComponent, createCommentVNode, createElementVNode, normalizeStyle, createStaticVNode, Fragment, toDisplayString, withDirectives, vShow } from "vue";
import "./duration.vue.mjs";
import DownIcon from "../../icons/down-icon.vue.mjs";
import UpIcon from "../../icons/up-icon.vue.mjs";
import _sfc_main$1 from "./duration.vue2.mjs";
const _hoisted_1 = {
  key: 0,
  class: "me-bubble-avatar"
};
const _hoisted_2 = { class: "me-bubble-box" };
const _hoisted_3 = {
  key: 0,
  class: "me-bubble-loading"
};
const _hoisted_4 = { class: "me-bubble-deep-think" };
const _hoisted_5 = {
  key: 0,
  class: "me-bubble-deep-think-loading"
};
const _hoisted_6 = { class: "me-bubble-deep-think-content" };
const _hoisted_7 = ["innerHTML"];
const _hoisted_8 = ["innerHTML"];
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "me-bubble"
  },
  __name: "bubble",
  props: {
    header: {},
    footer: {},
    avatar: { type: [String, Object, Function, null], default: null },
    content: {},
    loading: { type: Boolean, default: false },
    placement: {},
    shape: {},
    showDuration: { type: Boolean },
    done: { type: Boolean },
    messageRender: {},
    deepThink: { type: Boolean, default: false },
    deepThinkContent: {},
    deepThinkLoading: { type: Boolean, default: false }
  },
  setup(__props) {
    const props = __props;
    const showDeepThink = ref(true);
    const avatar = () => {
      const avatar2 = props.avatar;
      if (typeof avatar2 === "string") {
        return h("img", {
          src: avatar2,
          class: "me-bubble-avatar-img"
        });
      } else if (isVNode(avatar2)) {
        return avatar2;
      } else if (typeof avatar2 === "function") {
        return avatar2();
      } else {
        return null;
      }
    };
    const isAvatar = computed(() => {
      return props.avatar;
    });
    const footer = () => {
      const footer2 = props.footer;
      const showDuration = props.showDuration;
      if (typeof footer2 === "string" || isVNode(footer2)) {
        return showDuration ? h("div", {
          class: "me-bubble-footer"
        }, [h(_sfc_main$1, {
          done: props.done
        }), footer2]) : h("div", {
          class: "me-bubble-footer"
        }, footer2);
      } else if (typeof footer2 === "function") {
        return showDuration ? h("div", {
          class: "me-bubble-footer"
        }, [h(_sfc_main$1, {
          done: props.done
        }), footer2()]) : h("div", {
          class: "me-bubble-footer"
        }, footer2());
      } else {
        return showDuration ? h("div", {
          class: "me-bubble-footer"
        }, [h(_sfc_main$1, {
          done: props.done
        })]) : null;
      }
    };
    const shape = computed(() => {
      return props.shape || "round";
    });
    const header = () => {
      const header2 = props.header;
      if (typeof header2 === "string" || isVNode(header2)) {
        return h("div", {
          class: "me-bubble-header"
        }, header2);
      } else if (typeof header2 === "function") {
        return h("div", {
          class: "me-bubble-header"
        }, header2());
      } else {
        return null;
      }
    };
    const onClickDeepThinkBtn = () => {
      showDeepThink.value = !showDeepThink.value;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(["me-bubble", `me-bubble-${_ctx.placement}`])
      }, [
        isAvatar.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
          renderSlot(_ctx.$slots, "avatar", {}, () => [
            (openBlock(), createBlock(resolveDynamicComponent(avatar)))
          ])
        ])) : createCommentVNode("", true),
        createElementVNode("div", _hoisted_2, [
          renderSlot(_ctx.$slots, "header", {}, () => [
            (openBlock(), createBlock(resolveDynamicComponent(header)))
          ]),
          createElementVNode("div", {
            class: normalizeClass(["me-bubble-content", `me-bubble-content-${shape.value}`]),
            style: normalizeStyle({ ...isAvatar.value ? {} : { maxWidth: "100%" } })
          }, [
            _ctx.loading ? (openBlock(), createElementBlock("span", _hoisted_3, [
              renderSlot(_ctx.$slots, "loading", {}, () => [
                _cache[0] || (_cache[0] = createStaticVNode('<svg viewBox="0 0 36 36" width="1em" height="1em" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" data-icon="spin"><defs><linearGradient x1="0%" y1="100%" x2="100%" y2="100%" id="linearGradient-1"><stop stop-color="currentColor" stop-opacity="0" offset="0%"></stop><stop stop-color="currentColor" stop-opacity="0.50" offset="39.9430698%"></stop><stop stop-color="currentColor" offset="100%"></stop></linearGradient></defs><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect fill-opacity="0.01" fill="none" x="0" y="0" width="36" height="36"></rect><path d="M34,18 C34,9.163444 26.836556,2 18,2 C11.6597233,2 6.18078805,5.68784135 3.59122325,11.0354951" stroke="url(#linearGradient-1)" stroke-width="4" stroke-linecap="round"></path></g></svg>', 1))
              ])
            ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
              _ctx.deepThink ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                createElementVNode("div", _hoisted_4, [
                  createElementVNode("span", {
                    onClick: onClickDeepThinkBtn,
                    class: "me-bubble-deep-think-text"
                  }, [
                    createElementVNode("span", null, toDisplayString(_ctx.deepThinkLoading ? "思考中" : "思考结束"), 1),
                    !_ctx.deepThinkLoading ? (openBlock(), createBlock(resolveDynamicComponent(showDeepThink.value ? UpIcon : DownIcon), { key: 0 })) : createCommentVNode("", true)
                  ]),
                  _ctx.deepThinkLoading ? (openBlock(), createElementBlock("span", _hoisted_5, _cache[1] || (_cache[1] = [
                    createStaticVNode('<svg viewBox="0 0 36 36" width="1em" height="1em" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" data-icon="spin"><defs><linearGradient x1="0%" y1="100%" x2="100%" y2="100%" id="linearGradient-1"><stop stop-color="currentColor" stop-opacity="0" offset="0%"></stop><stop stop-color="currentColor" stop-opacity="0.50" offset="39.9430698%"></stop><stop stop-color="currentColor" offset="100%"></stop></linearGradient></defs><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect fill-opacity="0.01" fill="none" x="0" y="0" width="36" height="36"></rect><path d="M34,18 C34,9.163444 26.836556,2 18,2 C11.6597233,2 6.18078805,5.68784135 3.59122325,11.0354951" stroke="url(#linearGradient-1)" stroke-width="4" stroke-linecap="round"></path></g></svg>', 1)
                  ]))) : createCommentVNode("", true)
                ]),
                withDirectives(createElementVNode("div", _hoisted_6, [
                  typeof _ctx.deepThinkContent === "function" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.deepThinkContent()), { key: 0 })) : isVNode(_ctx.deepThinkContent) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.deepThinkContent), { key: 1 })) : (openBlock(), createElementBlock("div", {
                    key: 2,
                    class: "me-bubble-content-text",
                    innerHTML: _ctx.deepThinkContent
                  }, null, 8, _hoisted_7))
                ], 512), [
                  [vShow, showDeepThink.value]
                ])
              ], 64)) : createCommentVNode("", true),
              _ctx.messageRender ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.messageRender(_ctx.content)), { key: 1 })) : renderSlot(_ctx.$slots, "content", { key: 2 }, () => [
                typeof _ctx.content === "function" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.content()), { key: 0 })) : isVNode(_ctx.content) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.content), { key: 1 })) : (openBlock(), createElementBlock("div", {
                  key: 2,
                  class: "me-bubble-content-text",
                  innerHTML: _ctx.content
                }, null, 8, _hoisted_8))
              ])
            ], 64))
          ], 6),
          renderSlot(_ctx.$slots, "footer", {}, () => [
            (openBlock(), createBlock(resolveDynamicComponent(footer)))
          ])
        ])
      ], 2);
    };
  }
});
export {
  _sfc_main as default
};
//# sourceMappingURL=bubble.vue2.mjs.map
